RAIS  3.2
C:/Projekte/RAIS/common/Message.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Data;
00031 using System.Text;
00032 
00033 using RAIS.Common.UserManagement;
00034 using RAIS.Common.TableManagement;
00035 using ModificationTypes = System.Collections.Generic.Dictionary<RAIS.Common.MessageManagement.Message.ModificationType, RAIS.Common.MessageManagement.Message.ModificationTypeData>;
00036 using ValidationStatuses = System.Collections.Generic.Dictionary<RAIS.Common.MessageManagement.Message.ValidationStatus, RAIS.Common.MessageManagement.Message.ValidationStatusData>;
00037 using MessageTypes = System.Collections.Generic.Dictionary<RAIS.Common.MessageManagement.Message.MessageType, RAIS.Common.MessageManagement.Message.MessageTypeData>;
00038 
00039 namespace RAIS.Common.MessageManagement
00040 {
00044         [Serializable]
00045         public class Message
00046         {
00047                 //*********************************************************************
00048                 #region Enumerators
00049                 public enum ModificationType
00050                 {
00051                         Add = 0,
00052                         Edit,
00053                         Delete
00054                 }
00055                 public enum ValidationStatus
00056                 {
00057                         NotValidated = 0,
00058                         Released,
00059                         Rejected
00060                 }
00061                 public enum MessageType
00062                 { 
00063                         Validation = 0,
00064                         AccountRequest
00065                 }
00066                 #endregion
00067                 //*********************************************************************
00068                 #region Fields
00069                 static ModificationTypes modificationTypesDictionary;
00070                 static ValidationStatuses validationStatusesDictionary;
00071                 static MessageTypes messageTypesDictionary;
00072 
00073                 int id;
00074                 int userFromID;
00075                 string userFromName;
00076                 int? userToID = null;
00077                 string userToName = string.Empty;
00078                 int tableID;
00079                 string tableName;
00080                 int rowID;
00081                 int historyRowID;
00082                 string comment = string.Empty;
00083                 ModificationType modificationType;
00084                 ValidationStatus validationStatus;
00085                 DateTime timeStamp;
00086                 MessageType type = MessageType.Validation;
00087                 #endregion
00088                 //*********************************************************************
00089                 #region Properties
00090 
00091 
00092 
00093                 static public ModificationTypes ModificationTypesDictionary
00094                 {
00095                         get { return modificationTypesDictionary; }
00096                         set { modificationTypesDictionary = value; }
00097                 }
00101                 static public ValidationStatuses ValidationStatusesDictionary
00102                 {
00103                         get { return validationStatusesDictionary; }
00104                         set { validationStatusesDictionary = value; }
00105                 }
00109                 static public MessageTypes MessageTypesDictionary
00110                 {
00111                         get { return messageTypesDictionary; }
00112                         set { messageTypesDictionary = value; }
00113                 }
00117                 public int ID
00118                 {
00119                         get { return this.id; }
00120                         set { this.id = value; }
00121                 }
00125                 public int UserFromID
00126                 {
00127                         get { return this.userFromID; }
00128                         set { this.userFromID = value; }
00129                 }
00133                 public string UserFromName
00134                 {
00135                         get { return this.userFromName; }
00136                         set { this.userFromName = value; }
00137                 }
00141                 public int? UserToID
00142                 {
00143                         get { return this.userToID; }
00144                         set { this.userToID = value; }
00145                 }
00149                 public string UserToName
00150                 {
00151                         get { return this.userToName; }
00152                         set { this.userToName = value; }
00153                 }
00157                 public int TableID
00158                 {
00159                         get { return this.tableID; }
00160                         set { this.tableID = value; }
00161                 }
00165                 public string TableName
00166                 {
00167                         get { return this.tableName; }
00168                         set { this.tableName = value; }
00169                 }
00173                 public int RowID
00174                 {
00175                         get { return this.rowID; }
00176                         set { this.rowID = value; }
00177                 }
00181                 public int HistoryRowID
00182                 {
00183                         get { return this.historyRowID; }
00184                         set { this.historyRowID = value; }
00185                 }
00189                 public string Comment
00190                 {
00191                         get { return this.comment; }
00192                         set { this.comment = value; }
00193                 }
00197                 public ModificationType Modification
00198                 {
00199                         get { return this.modificationType; }
00200                         set { this.modificationType = value; }
00201                 }
00205                 public ModificationTypeData ModificationData
00206                 {
00207                         get { return modificationTypesDictionary[this.modificationType]; }
00208                 }
00212                 public string ModificationVisibleName
00213                 {
00214                         get { return ModificationData.VisibleName; }
00215                 }
00219                 public ValidationStatus Validation
00220                 {
00221                         get { return this.validationStatus; }
00222                         set { this.validationStatus = value; }
00223                 }
00227                 public ValidationStatusData ValidationData
00228                 {
00229                         get { return validationStatusesDictionary[this.validationStatus]; }
00230                 }
00234                 public string ValidationVisibleName
00235                 {
00236                         get { return ValidationData.VisibleName; }
00237                 }
00241                 public DateTime TimeStamp
00242                 {
00243                         get { return this.timeStamp; }
00244                         set { this.timeStamp = value; }
00245                 }
00249                 public MessageType Type
00250                 {
00251                         get { return this.type; }
00252                         set { this.type = value; }
00253                 }
00257                 public MessageTypeData TypeData
00258                 {
00259                         get { return MessageTypesDictionary[this.Type]; }
00260                 }
00261                 #endregion
00262                 //*********************************************************************
00263                 #region Constructors
00264                 public Message()
00265                 {}
00266 
00267                 public Message(IDataRecord record)
00268                 {
00269                         this.ID = (int)record["PK Message ID"];
00270                         this.userFromID = (int)record["FK User-From ID"];
00271                         this.userFromName = record["User-From Name"].ToString();
00272                         if (!(record["FK User-To ID"] is DBNull))
00273                         {
00274                                 this.userToID = (int)record["FK User-To ID"];
00275                                 this.userToName = record["User-To Name"].ToString();
00276                         }
00277                         this.tableID = (int)record["FK Table ID"];
00278                         this.tableName = record["Table Name"].ToString();
00279                         this.rowID = (int)record["Row ID"];
00280                         this.historyRowID = (record["History Row ID"] is DBNull)
00281                                 ? 0
00282                                 : (int)record["History Row ID"];
00283                         this.comment = record["Comment"].ToString();
00284                         this.modificationType = (ModificationType)Enum.Parse(typeof(ModificationType), record["Modification Type Name"].ToString());
00285                         this.validationStatus = (ValidationStatus)Enum.Parse(typeof(ValidationStatus), record["Validation Status Name"].ToString());
00286                         this.timeStamp = (DateTime)record["RAIS_TIME_STAMP"];
00287                         this.type = (MessageType)Enum.Parse(typeof(MessageType), record["Message Type Name"].ToString());
00288                 }
00289                 #endregion
00290                 //*********************************************************************
00291                 #region Nested classes
00292                 public class ModificationTypeData
00293                 {
00294                         //*********************************************************************
00295                         #region Fields
00296                         int id;
00297                         string name;
00298                         string visibleName;
00299                         #endregion
00300                         //*********************************************************************
00301                         #region Properties
00302 
00303 
00304 
00305                         public int ID
00306                         {
00307                                 get { return this.id; }
00308                         }
00312                         public ModificationType Type
00313                         {
00314                                 get { return (ModificationType)Enum.Parse(typeof(ModificationType), this.name); }
00315                         }
00319                         public string VisibleName
00320                         {
00321                                 get { return this.visibleName; }
00322                         }
00323                         #endregion
00324                         //*********************************************************************
00325                         #region Constructors
00326                         public ModificationTypeData()
00327                         { }
00328                         public ModificationTypeData(IDataRecord record)
00329                         {
00330                                 this.id = (int)record["PK Modification Type ID"];
00331                                 this.name = record["Modification Type Name"].ToString();
00332                                 this.visibleName = record["Modification Type Visible Name"].ToString();
00333                         }
00334                         #endregion
00335                 }
00336 
00337                 public class ValidationStatusData
00338                 {
00339                         //*********************************************************************
00340                         #region Fields
00341                         int id;
00342                         string name;
00343                         string visibleName;
00344                         #endregion
00345                         //*********************************************************************
00346                         #region Properties
00347 
00348 
00349 
00350                         public int ID
00351                         {
00352                                 get { return this.id; }
00353                         }
00357                         public ValidationStatus Type
00358                         {
00359                                 get { return (ValidationStatus)Enum.Parse(typeof(ValidationStatus), this.name); }
00360                         }
00364                         public string VisibleName
00365                         {
00366                                 get { return this.visibleName; }
00367                         }
00368                         #endregion
00369                         //*********************************************************************
00370                         #region Constructors
00371                         public ValidationStatusData()
00372                         { }
00373                         public ValidationStatusData(IDataRecord record)
00374                         {
00375                                 this.id = (int)record["PK Validation Status ID"];
00376                                 this.name = record["Validation Status Name"].ToString();
00377                                 this.visibleName = record["Validation Status Visible Name"].ToString();
00378                         }
00379                         #endregion
00380                 }
00381                 public class MessageTypeData : DBTypeObject
00382                 {
00383                         //*********************************************************************
00384                         #region Properties
00385 
00386 
00387 
00388                         public MessageType Type
00389                         {
00390                                 get { return (MessageType)Enum.Parse(typeof(MessageType), this.name); }
00391                         }
00392                         #endregion
00393                         //*********************************************************************
00394                         #region Constructors
00395                         public MessageTypeData()
00396                         { }
00397                         public MessageTypeData(IDataRecord record)
00398                         {
00399                                 this.id = (int)record["PK Message Type ID"];
00400                                 this.name = record["Message Type Name"].ToString();
00401                                 this.visibleName = record["Message Type Visible Name"].ToString();
00402                         }
00403                         #endregion
00404                 }
00405                 #endregion
00406         }
00407 }